package priv.bestbeat.reportcenter.core.mq;

import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;

/**
 * @author 张渠钦
 * @date 2022/4/24 17:58
 * @param <T> 可消息化对象
 */
@Data
public abstract class Message<T> implements Messageable<T>, MessageStateful<Message> {

    /**
     * 消息负载
     */
    private T payload;

    /**
     * 消息状态
     */
    @Setter(AccessLevel.NONE)
    private MessageStateEnum state;

    @Override
    public Message sendDone() {
        this.state = MessageStateEnum.DONE;
        return this;
    }

    @Override
    public Message sendFail() {
        this.state = MessageStateEnum.FAILED;
        return this;
    }
}
